cc.Class({
    extends: cc.Component,

    properties: {
        prefabLevelItem: cc.Prefab,

        labelLevelName: cc.Label,
        labelLevelRange:cc.Label,

        levelItemcontent: cc.Node,
        isAllPass:cc.Node,

        sceneBgSprites:[cc.SpriteFrame],

        nodeParent:null,
        index:null,
    },

    // start() {
    //     this._labelLevelName = this.node.getChildByName("txt_levelname");
    //     this._levelItemcontent = this.node.getChildByName("img_levelitem_content");
    // },
    /**
     * 创建时使用
     * @param {} data
     */
    setLevelData(data,index) {
        if (data) {
            this.labelLevelName.string = data.gameScene;

            var level = window.gameConfig.gameData.level;//关卡
            this.index = (index + 1) * 6;
            if(level > this.index)this.isAllPass.active = true;
            else this.isAllPass.active = false;

            //是否开启关卡
            var startLevelNum=(data.level-6)+1;
            var isOpenLevel=level-startLevelNum>=0?0:1;
            //更换图片
            var contentSprite=this.levelItemcontent.getComponent(cc.Sprite);
            contentSprite.spriteFrame=this.sceneBgSprites[(index*2)+isOpenLevel];
            this.labelLevelRange.string=startLevelNum+" - "+data.level;
        } else {
            cc.log("无关卡数据");
        }
    },
    /**
     * 更新关卡数据
     */
    updateLevelData(data,number){

    },

    onButtonJoinGameSceneCallback:function(){
        window.audioMgr.playGameAudio("buttonCheck")
        this.nodeParent.showLevelContent(this.index);
    },

});